/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hd2tecnologia.utilidades;
import java.net.MalformedURLException;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.JOptionPane;

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.URI;
import javax.swing.ImageIcon;

/**
 *
 * @author Júnior
 */
public class SystemUtil {
    
    private static final long serialVersionUID = 1L;
    private static final Logger _log = Logger.getLogger(SystemUtil.class.getName());    
    Diretorios dir = new Diretorios();
    Icones icone = new Icones();
    
    /**
     * Verifica o O.S
     */    
    public String VerificarSO(){
        return System.getProperty("os.name");
    }
    
   
    public void Exibir(String msg, String title , Boolean playSound, String som, ImageIcon icone) {

        _log.info("enviando janela de mensagem... \n");

        if (playSound) {
            
            try {
                
                File file = new File(dir.SOUND_PATH.concat(som));
                URI caminho = file.toURI();
                AudioClip sound;
                sound = Applet.newAudioClip(caminho.toURL());
                sound.play();
                
            } catch (MalformedURLException ex) {
                Logger.getLogger(SystemUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        JOptionPane.showMessageDialog(null, msg , title , JOptionPane.INFORMATION_MESSAGE, icone);
    }
    
    
    public void tocar(Boolean playSound, String som){
        
        if (playSound) {
            
            try {
                
                File file = new File(dir.SOUND_PATH.concat(som));
                URI caminho = file.toURI();
                AudioClip sound;
                sound = Applet.newAudioClip(caminho.toURL());
                sound.play();
                
            } catch (MalformedURLException ex) {
                Logger.getLogger(SystemUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
        }        
        
    }
    
    
}
